package com.xca.znb.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.xca.znb.R;
import com.xca.znb.entity.NewsLetter;
import com.xca.znb.entity.User;

import java.util.List;

public class MyMessageAdapter extends BaseAdapter {
    private Context context ;
    private List<NewsLetter> newsLetterList ;

    @Override
    public int getCount() {
        return newsLetterList.size();
    }

    @Override
    public Object getItem(int position) {
        return newsLetterList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder ;
        if (convertView == null){
            LayoutInflater inflater = LayoutInflater.from(context);
            convertView = inflater.inflate(R.layout.newsletter_item , parent , false );
            viewHolder = new ViewHolder() ;
            viewHolder.showImg = convertView.findViewById(R.id.newsletter_show_img) ;
            viewHolder.showName = convertView.findViewById(R.id.newsletter_show_name);
            viewHolder.showId = convertView.findViewById(R.id.newsletter_show_phone);
            viewHolder.showTime = convertView.findViewById(R.id.newsletter_show_time);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag() ;
        }

        NewsLetter newsLetter = newsLetterList.get(position);
        viewHolder.showImg.setImageResource(R.drawable.goods_managerment);

        return null;
    }

    static class ViewHolder{
        ImageView showImg ;
        TextView showName ;
        TextView showId ;
        TextView showTime ;
    }
}
